Skip to content

Support external Bitcoin nodes in hashi-localnet CLI#365

Open
0xsiddharthks wants to merge 3 commits intomainfrom
siddharth/e2e-test-signet
Open

Support external Bitcoin nodes in hashi-localnet CLI#365
0xsiddharthks wants to merge 3 commits intomainfrom
siddharth/e2e-test-signet

Conversation

@0xsiddharthks
Copy link
Copy Markdown
Contributor

Extends the hashi-localnet CLI to support running against external Bitcoin nodes (signet, testnet4), instead of only spawning a local regtest instance.

Usage

  # Regtest (unchanged default behavior)                                                                                                          
  hashi-localnet start                                                                                                                          
                                                                                                                                                  
  # Signet (connects to local signet node)
  hashi-localnet start --bitcoin-network signet \                                                                                                 
    --btc-rpc-url http://127.0.0.1:38332 \                                                                                                      
    --btc-wallet my_signet_wallet \                                                                                                               
    -v
                                                                                                                                                  
  # Then in another terminal:                                                                                                                     
  hashi-localnet deposit --amount 10000

Base automatically changed from siddharth/signet-migration to main March 30, 2026 17:18
@Bridgerz
Copy link
Copy Markdown
Contributor

Bridgerz commented Apr 2, 2026

Wonder if it would be possible to support external Sui network (devnet / testnet) too?

@0xsiddharthks 0xsiddharthks force-pushed the siddharth/e2e-test-signet branch 2 times, most recently from 223c348 to 355d8e5 Compare April 6, 2026 12:35
@0xsiddharthks
Copy link
Copy Markdown
Contributor Author

@Bridgerz
i was trying to do that.. but that would require patching some move smart contracts during runtime because the hashi contract requires registrants to be actual Sui validators
https://github.com/MystenLabs/hashi/blob/main/packages/hashi/sources/core/committee/committee_set.move#L113-L137

I have created a test implementation ( #407 ) which patches this function right before publishing the contract artifacts. but tbh it doesn't feel good.

Not sure if we should try to do it.

@0xsiddharthks 0xsiddharthks force-pushed the siddharth/e2e-test-signet branch from 56da15b to 11d4b50 Compare April 6, 2026 15:42
@0xsiddharthks
Copy link
Copy Markdown
Contributor Author

also wrapped all synchronous calls from corepc with tokio::task::spawn_blocking()

@0xsiddharthks 0xsiddharthks force-pushed the siddharth/e2e-test-signet branch from 11d4b50 to 1fd688e Compare April 6, 2026 15:43
@0xsiddharthks 0xsiddharthks marked this pull request as ready for review April 6, 2026 15:43
@0xsiddharthks 0xsiddharthks requested a review from bmwill as a code owner April 6, 2026 15:43
Add --bitcoin-network flag to `hashi-localnet start` to connect to
external Bitcoin nodes (signet, testnet4) instead of spawning a local
regtest instance.
Qualify the rustdoc link to fix `make doc` CI failure.
The corepc-client uses the client-sync feature, so all Bitcoin Core
RPC calls are blocking HTTP requests.  When called from async
functions they block the tokio worker thread.

- Wrap Client in Arc<Client> in BitcoinNodeHandle and
  ExternalBitcoinNode so it can be cloned into spawn_blocking closures
- Convert send_to_address, generate_blocks, get_new_address,
  get_balance, get_block_count to async with spawn_blocking
- Wrap RPC calls in cmd_deposit poll loops with spawn_blocking
- Persist btc_wallet in LocalnetState so deposit uses the correct
  wallet on non-regtest networks
- Add crate-level spawn_blocking helper (same pattern as
  mpc_except_signing.rs)
@0xsiddharthks 0xsiddharthks force-pushed the siddharth/e2e-test-signet branch from 1fd688e to 6a287a8 Compare April 6, 2026 16:22
Comment on lines +25 to +38
/// Trait for Bitcoin node connectivity used by the hashi network builder.
pub trait BitcoinNodeInfo {
fn rpc_url(&self) -> &str;
fn p2p_address(&self) -> String;
}

impl BitcoinNodeInfo for crate::BitcoinNodeHandle {
fn rpc_url(&self) -> &str {
self.rpc_url()
}
fn p2p_address(&self) -> String {
self.p2p_address()
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this trait?

dir: &Path,
sui: &SuiNetworkHandle,
bitcoin: &BitcoinNodeHandle,
bitcoin: &impl BitcoinNodeInfo,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it maybe be better to just pass in the rpc and p2p values directly vs needing to go through a trait?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants